import store from 'store'
export function LinkTo(link, orderStatus, type) {
    // 获取login ,判断是否登录
    let login = uni.getStorageSync('login');
    let userInfo = store.state.mineState.userInfo;
    // 如果未登录，不能执行跳转操作
    if (!login) {
        uni.$emit('loginHandle', 'login');
        return;
    }
    // 如果没有绑定手机号，则先绑定手机号
    if (!!userInfo.status) {
        uni.$emit('loginHandle', 'bindPhone');
        return;
    }
    switch (link) {
        case 'bookstorePlan':
            uni[type || 'navigateTo']({
                url: '/pagesMine/bookstore/readingPlanOut',
            });
            break;
        case 'bookstoreBaogao':
            uni.navigateTo({
                url: '/pagesMine/bookstore/baogao',
            });
            break;
        case 'bookstore':
            uni.navigateTo({
                url: '/pagesMine/bookstore/index',
            });
            break;
        case 'copartner':
            if(!store.getters.vipCardNum || !this.$store.getters.becomeShareAddTime){
                uni.navigateTo({
                    url: '/pagesMine/copartner/vip-power',
                });
            } else {
                uni.navigateTo({
                    url: '/pagesMine/copartner/index',
                });
            }

            break;
        case 'vip':
            uni[type || 'navigateTo']({
                url: `/pagesMine/vip/vip-center?type=${!orderStatus ? 1 : 2}`,
            });
            break;
        case 'giftGard':
            uni.navigateTo({
                url: '/pagesMine/giftGard/index',
            });
            break;
        case 'setting':
            uni.navigateTo({
                url: '/pagesMine/setting/index',
            });
            break;
        case 'collection':
            uni.navigateTo({
                url: '/pagesMine/collection/collection',
            });
            break;
        case 'address':
            uni.navigateTo({
                url: '/pagesMine/address/address',
            });
            break;
        case 'wallet':
            uni.navigateTo({
                url: '/pagesMine/wallet/index',
            });
            break;
        case 'order':
            uni.navigateTo({
                url: `/pagesMine/orderManagement/index?orderStatus=${orderStatus}`,
            });
            break;
        case 'help':
            uni.navigateTo({
                url: '/pagesMine/help/help-list',
            });
            break;
    }

}
export default {
    LinkTo
}
